/**
 * 上传文件函数
 * @param tempFilePath 文件本地路径
 * @returns
 * @author lian
 */
export const uploadFile = (tempFilePath: string): Promise<string> => {
  return new Promise((resolve, reject) => {
    uni.uploadFile({
      url: import.meta.env.HOPE_API_BASE_URL + UploadApi.UPLOAD,
      filePath: tempFilePath,
      name: 'file',
      success: (res) => {
        const { data } = JSON.parse(res.data)
        // 返回上传之后的路径
        resolve(data)
      },
      fail(res) {
        showSimpleToast(UPLOAD_FAILURE)
        console.log(res)
        reject(res)
      },
    })
  })
}
